package cn.itqiqi.student_system_java.controller;

import cn.hutool.json.JSONUtil;
import cn.itqiqi.student_system_java.pojo.User;
import cn.itqiqi.student_system_java.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kevin_琪琪
 * @version 1.0
 * @description
 * @date 2022-06-20 11:28
 */
@RestController
public class UserController {

    @Autowired
    private UserServiceImpl userService;

    @PostMapping("/login")
    public String login(@RequestBody String user) {
        User userBean = JSONUtil.toBean(user, User.class);
        return userService.login(userBean.getUsername(), userBean.getPassword());
    }

    @PostMapping("/loginVerify")
    public String loginVerify(@RequestBody String token) {
        return userService.loginVerify(token);
    }

}
